﻿@using LTMCompanyNameFree.YoyoCmsTemplate.Web.ViewModels.Common.Modals
@model LTMCompanyNameFree.YoyoCmsTemplate.Web.ViewModels.Roles.EditRoleModalViewModel
@{
    Layout = null;
}
@Html.Partial("~/Views/Shared/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(L("EditRole")))

<div class="modal-body">
    <form name="RoleEditForm" role="form" novalidate class="form-validation">
        <input type="hidden" name="Id" value="@Model.Role.Id" />
        <input type="hidden" name="IsStatic" value="@(Model.Role.IsStatic.ToString())" />
        <div class="row clearfix">
            <div class="col-sm-12">
                <div class="form-group form-float">
                    <div class="form-line">
                        <label for="rolename">@L("RoleName")</label>
                        <input id="rolename" @(Model.Role.IsStatic ? "disabled" : "") type="text" name="Name" value="@Model.Role.Name" required maxlength="32" minlength="2" class="validate form-control">

                    </div>
                </div>
            </div>
        </div>

        <div class="row clearfix">
            <div class="col-sm-12">
                <div class="form-group form-float">
                    <div class="form-line">
                        <label for="displayname">@L("DisplayName")</label>
                        <input id="displayname" type="text" name="DisplayName" value="@Model.Role.DisplayName" required maxlength="32" minlength="2" class="validate form-control">

                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group form-float">
                    <div class="form-line">
                        <label for="role-description">@L("RoleDescription")</label>
                        <textarea id="role-description" name="Description" class="validate form-control">@Model.Role.Description</textarea>

                    </div>
                </div>
            </div>
        </div>

        <div class="row clearfix">
            <div class="col-sm-12">
                <h4>@L("Permissions")</h4>

                @foreach (var permission in Model.Permissions)
                {
                    <span class="col-sm-4">
                        <input type="checkbox" name="permission" value="@permission.Name" class="filled-in" id="@string.Format("permission{0}", permission.Name)" @(Model.HasPermission(permission) ? "checked" : "") @(Model.Role.IsStatic ? "disabled" : "")/>
                        <label for="@string.Format("permission{0}",permission.Name)">@permission.DisplayName</label>

                    </span>
                }
            </div>
        </div>
    </form>
</div>

@Html.Partial("~/Views/Shared/Modals/_ModalFooterWithSaveAndCancel.cshtml")

<script src="~/view-resources/Views/Roles/_EditRoleModal.js" asp-append-version="true"></script>
